#!/usr/bin/env python
# -*-coding:utf-8 -*-
# ==============================================================================
# Copyright (c) 2024 laugh12321 Authors. All Rights Reserved.
#
# Licensed under the GNU General Public License v3.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.gnu.org/licenses/gpl-3.0.html
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
# File    :   c_lib_wrap.py
# Version :   6.1.0
# Author  :   laugh12321
# Contact :   laugh12321@vip.qq.com
# Date    :   2024/07/03 13:12:29
# Desc    :   A script to locate and load necessary CUDA and TensorRT libraries.
# ==============================================================================
import os
import sys

from loguru import logger

logger.configure(handlers=[{'sink': sys.stdout, 'colorize': True, 'format': "<level>[{level.name[0]}]</level> <level>{message}</level>"}])


if os.name == "nt":
    need_lib_dirs = [r"${CUDAToolkit_BIN_DIR}", r"${TRT_LIB_DIR}"]
    for need_lib_dir in need_lib_dirs:
        sys.path.insert(0, need_lib_dir)
        if sys.version_info[:2] >= (3, 8):
            os.add_dll_directory(need_lib_dir)

try:
    from .libs.pydeploy import *
except Exception as e:
    raise RuntimeError(f"Deploy initialization failed! Error: {e}")
